//
//  ViewController.swift
//  show
//
//  Created by 李威 on 2022/2/23.
//

import UIKit
import SnapKit

class ViewController: UIViewController, UIScrollViewDelegate {

    let container = UILayoutGuide()
    
    override func viewDidLoad() {
        super.viewDidLoad()
//        let scrollView = UIScrollView(frame: CGRect(x: 20, y: 50, width: 200, height: 300));
//        scrollView.backgroundColor = .yellow;
//        scrollView.delegate = self
//        scrollView.contentSize = CGSize(width: 250, height: 350);
//        view .addSubview(scrollView);
    }
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        print("\(#function)");
    }
    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        print("\(#function)");
    }
    func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
        print("\(#function)");
    }
    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        print("\(#function)----\(decelerate)");
    }
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        print("\(#function)");
    }
    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        print("\(#function)---\(velocity)---\(targetContentOffset)");
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("touch begin")
    }
    
    func layoutGuideDemo() {
        let label = UILabel()
        label.text = "UILabelUILabelUILabel"
        view.addSubview(label)
        
        let testView = UIView()
        testView.backgroundColor = UIColor.cyan
        view.addSubview(testView)
        
        view.addLayoutGuide(container)
        
        label.snp.makeConstraints { (make) in
            make.left.equalTo(container)
            make.centerY.equalTo(container)
        }
        
        testView.snp.makeConstraints { (make) in
            make.left.equalTo(label.snp.right).offset(20)
            make.height.equalTo(40)
            make.width.equalTo(120)
            make.right.equalTo(container)
            make.centerY.equalTo(container)
        }
        container.snp.makeConstraints { (make) in
           make.height.equalTo(5)
           make.center.equalTo(view)
       }
    }


}

